/*
 * def.hpp
 *
 *  Created on: 10 déc. 2011
 *      Author: Elca
 */

#ifndef DEF_HPP_
#define DEF_HPP_

#define LL  unsigned long long
#define LONLONGBITS sizeof(LL)*8
#define LONLONGBITSM1 LONLONGBITS-1
#define LLBITSDIV2 LONLONGBITS/2

#define cas32(p, o, n)      __sync_val_compare_and_swap(p, o, n)
#define cas64(p, o, n)      __sync_val_compare_and_swap(p, o, n)
#define casptr(p, o, n)     __sync_val_compare_and_swap(p, o, n)
#define bcas32(p, o, n)     __sync_bool_compare_and_swap(p, o, n)
#define bcas64(p, o, n)     __sync_bool_compare_and_swap(p, o, n)
#define bcasptr(p, o, n)    __sync_bool_compare_and_swap(p, o, n)

//p=Adress to increment, o = increment
#define AtomicFetchAndIncrement(p,o) __sync_fetch_and_add(p,o)

//p=Adress to decrement, o = decrement
#define AtomicFetchAndDecrement(p,o) __sync_fetch_and_sub(p,o)

#endif /* DEF_HPP_ */
